package zookeeper;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

/**
 * Author 李岩飞
 * Email eliyanfei@126.com
 * 2017/12/27
 */
public class CountDemo {
    private static CountDownLatch connectedSemaphore = new CountDownLatch(5);
    public static void main(String[] args) {
        for(int i=0;i<5;i++){
            new Thread(()->{
                try {
                    TimeUnit.SECONDS.sleep(10);
                    System.out.println(Thread.currentThread().getName()+".end");
                    connectedSemaphore.countDown();
                }catch (Exception e){
                    e.printStackTrace();
                }
            }).start();
        }
        try {
            connectedSemaphore.await();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("end");
    }
}
